const vm = new Vue({
    el: '#main',
    data: {
        content: '',
        commentId: '',
    },
    methods: {
        submit,
    },
});

function apiready() {
    fxj.fixLayout();
    !async function () {
        vm.commentId = await reqCommentId(fxj.getSearch().get('id'));
    }();
}

async function submit() {
    const close = fxj.dialog.loading({noBg: true});
    const res = await ajax({
        url: 'home/userComment/leaveMsg',
        data: {
            content: vm.content,
            orderId: fxj.getSearch().get('id'),
            commentId: vm.commentId,
        },
    });
    close();
    toast(res.msg);
    if (res.err === 0) {
        setTimeout(() => {
            closeToWin();
        }, 2000);
    }
}

async function reqCommentId(orderId) {
    const res = await ajax({
        url: 'home/userComment/getCommentId',
        data: {
            orderId,
        },
    });
    return res.data;
}